package hzst.android.form.view;


import hzst.android.Constants;
import hzst.android.form.info.BaseViewInfo.SubmitValue;
import hzst.android.form.info.SelectableViewInfo;

import java.util.List;

import android.content.Context;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
/**
 * 多选框组
 * @author wt
 *
 */
public class FMCheckGroup extends FMBaseView{

	public FMCheckGroup(Context context) {
		super(context);
	}

	
	@Override
	public void showView() {
		
		List<SubmitValue> submitValues = info.getSubmitValues();
		for (int i = 0; i < ((SelectableViewInfo)info).getListText().size(); i++) {
			CheckBox cb = new CheckBox(context);
			cb.setTag(i);//为多选框添加下标
			cb.setText(((SelectableViewInfo)info).getListText().get(i));
			addView(cb);
			
			if(Constants.TRUE.equals(submitValues.get(i).getValue())){
				cb.setChecked(true);
			}
			if(info.isReadOnly()){
				cb.setEnabled(false);
				continue;
			}
			
			cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
				
				@Override
				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
					
				}
			});
		}
	}
}
